package collector;

import collector.interfaces.IInfoCollector;
import collector.util.BeanUtils;
import collector.util.Configuration;

public class Collector {

    @SuppressWarnings("unchecked")
    public static IInfoCollector getInstance(String url) {
        IInfoCollector instance = null;
        for (String type : Configuration.types) {
            if (Configuration.pages.get(type).contains(url)) {
                String clazz = Configuration.clazz.get(type);
                if (null != clazz) {
                    Class _class = BeanUtils.loadClass(clazz);
                    if (null != _class) {
                        instance = (IInfoCollector) BeanUtils.loadInstance(_class);
                    }
                }
                break;
            }
        }
        return instance;
    }
    
}
